@extends('layout')
@section('css')
<style> 
    body,html{
        height:100%;
    }
    .content{
        height:100%;
    }
    .form-group{
        width:6rem;
        margin:auto;
        background-color:rgba(0,0,0,0.4);
        border-radius:0.1rem;
        padding:0.2rem;
    }
    #phone{
        margin:0.3rem 0;
    }
    .phoneLabel{
        font-size:0.3rem;
        text-align:center;
        display:block;
    }
    .title{
        text-align:center;
        font-size:0.4rem;
        color:#f9cc6d;
    }
    .mylable{
        color:#f1f1f1;
        font-size:0.3rem;
    }
    .myinput{
        border:1px solid #c79f41;
        font-size:0.32rem;
        border-radius:0.1rem;
        border-width:0.05rem;
    }
    #code{
        width:2rem;
    }
    .sendCode{
        background-image:url("{{URL::asset('img/sendcode.png')}}");
        width:1.7rem;
        height:0.6rem;
        vertical-align:bottom;
        background-size:100% 100%;
        display:inline-block;
    }
    .summit{
        background-image:url("{{URL::asset('img/summit.png')}}");
        height:0.7rem;
        background-size:100% 100%;
        margin-top:0.3rem;
    }
    .tip{
        font-size:0.35rem;
        color:#f1f1f1;
        padding:0.3rem;
    }
</style>
@endsection
@section('content')
<div>
    <img src="{{URL::asset('img/banner.png')}}" width="100%">
    <div class="form-group">
        <p  class="title">验证手机号</p>
        <div>
            <lable for="phone" class="mylable">输入手机号</lable>
            <input type="tel" id="phone" class="myinput">
        </div>
        <div>
            <lable for="code" class="mylable">输入验证码</lable>
            <input type="tel" id="code" class="myinput">
            <span class="sendCode"></span>
        </div>
        <div class="summit"></div>
    </div>
    <div class="tip">
        领取的红包必须大于1元
    </div>
</div>
@endsection
@section('script')
<script>
    var openid = "{{$openid}}";
    $('.sendCode').on('click',function(){
        var phone = $('#phone').val();  
        $.ajax({
            url:'/sendCode',
            data:{'phone':phone},
            dataType:'JSON',
            type:'POST',
            success:function(data){
                if(data.code==201){
                    $('#prompt').modal('show');
                    $('#prompt text').text(data.msg);
                }
            }
        });
    });
    $('.summit').on('click',function(){
        if(openid==''){
            location.reload();
        }
        var phone = $('#phone').val();
        var code = $('#code').val();
        $.ajax({
            url:'/getMoney',
            dataType:'JSON',
            type:'POST',
            data:{'phone':phone,'openid':openid,'code':code},
            success:function(data){
                if(data.code==200){
                    alert('提现成功，请查看你的红包');
                }else if(data.code==202){
                    $('#prompt').modal('show');
                    $('#prompt text').text(data.msg);
                }else{
                    alert('提现失败，请重试');
                }
            }
        });
    });
</script>
@endsection